//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "framework\fn_updateObjectMarker.sqf"
#include <tmf_constants.h>
#include <tmf_macros.h>

TRACE_1("Start",_this);
TMFPROFILERSTART;

// The object marker should be added to a local array which is common to all instances and is used by the FSM
// It should then also be added to the instance variable store, so you an delete the selected markers when deleting the mission

// We need to pass the marker params AS IS to the updateMarker function so it adds/deletes the markers like regular ones.
// It's the FSM which needs to test the availability of the marker and delete it from the local array when not found.
private ["_instance_id","_object","_marker_array","_marker_name"];
DEFAULT_PARAM(_instance_id,0,TMF_SERVER_INSTANCE_ID);
DEFAULT_PARAM(_object,1,objNull);
DEFAULT_PARAM(_marker_array,2,[]);

if (isnil QGVAR(MARKER_INDEX)) then { GVAR(MARKER_INDEX) = 0; };

_marker_name = _object getVariable [Format[QGVAR(FOLLOW_MARKER_%1),_instance_id],""];
if (_marker_name == "") then {
	INC(GVAR(MARKER_INDEX));
	_marker_name = format[QGVAR(MARKER_%1),GVAR(MARKER_INDEX)];
};

_marker_array = [[_marker_name,position _object], _marker_array] call FFUNC(arrayPushStack);

TLOG("TODO: Add the follow marker logic",_marker_array);

TRACE("End");
TMFPROFILERSTOP;